import easygui
import re
import pathlib

root=pathlib.Path(__file__).parent
print(root/"input.txt")
outputTxt="name,kh,zh,kc\n"
name=""
kh=""
zh=""
with open(root/'input.txt', 'r', encoding='utf-8') as file:
    lines = file.readlines()
    
    for line in lines:
        result=re.search(r'第\d+考场',line)
        
        if(result != None):
            print(result.group())
            outputTxt +=",,,新街中学\n,,,"+result.group()+"\n"

        else:
            subt=line.split("\t")
            if(len(subt)>1):
                for i in subt :
                    if(i=="考号:"):
                        kh=subt[subt.index(i)+1]
                    if(i=="座位号:"):
                        zh=subt[subt.index(i)+1]
                    if(i=="姓名:"):
                        name=subt[subt.index(i)+1]
                        name=name.strip()
                        kh=kh.strip()
                        zh=zh.strip()
                        outputTxt += f"姓名:{name},考号:{kh},座位号:{zh},\n"
                
            # print(subt)            

with open("output.txt", 'w') as f:
    f.write(outputTxt)
